import {
  Toast
} from "vant";
import cTitle from "components/title";

export default {
  data() {
    return {
      // tab选项
      tabList: [{
          title: "直招客户经理榜单",
          index: "0",
        },
        {
          title: "直推个人法服榜单",
          index: "1",
        },
      ],
      list: [],
    //   personList: {},
      tabsId: 0, //默认选型为装备
    };
  },

  components: {
    cTitle
  },
  activated() {
    this.getZZList();
  },
  computed: {

  },
  methods: {
    goback(){
        this.$router.go(-1);
    },
    //点击tab时触发
    tabsOn(index) {
      this.tabsId = index;
      this.list = [];
      if(index == 0){
        this.getZZList();
      }else if(index == 1){
        this.getFFList();
      }
    },
   
    
    getZZList() {
      $http.get("ZhengChengYc.zrzRank", {}, "加载中").then((res) => {
        if (res.result == 1) {
          console.log(res, 'shuju_list')
          let array = res.data;
        array.forEach(item => {
          var str = item.avatar;
          var new1 = str.replace("http://shops.cg500.com/static/upload/", "https://shops.cg500.com/static/upload/");
          var new2 = str.replace("/static", "https://shops.cg500.com/static");
          var new3 = str.replace("images", "https://shops.cg500.com/static/upload/images");
          console.log(new1,'strrrrr',new1.indexOf('images'))
          if(new1.indexOf('images') == 0){
            item.avatar = new3
          }else if(new1.indexOf('images') == 8){
            item.avatar = new2
          }else {
            item.avatar = new1
          }
        });
        console.log(res.data.data)
        this.list = array;
        console.log(this.list, 'list')
        }
      });
    },
    getFFList() {
        $http.get("ZhengChengYc.ffRank", {}).then((res) => {
          if (res.result == 1) {
            console.log(res, 'shuju_list')
            let array = res.data;
          array.forEach(item => {
            var str = item.avatar;
            var new1 = str.replace("http://shops.cg500.com/static/upload/", "https://shops.cg500.com/static/upload/");
            var new2 = str.replace("/static", "https://shops.cg500.com/static");
            var new3 = str.replace("images", "https://shops.cg500.com/static/upload/images");
            console.log(new1,'strrrrr',new1.indexOf('images'))
            if(new1.indexOf('images') == 0){
              item.avatar = new3
            }else if(new1.indexOf('images') == 8){
              item.avatar = new2
            }else {
              item.avatar = new1
            }
          });
          console.log(res.data.data)
          this.list = array;
          console.log(this.list, 'list')
          }
        });
      },
  }
};